static gboolean opt_alias;
static char *opt_create;
static gboolean opt_collections;
+static gboolean opt_force;
/* ATTENTION:
* Please remember to update the bash-completion script (bash/ostree) and
{ "alias", 'A', 0, G_OPTION_ARG_NONE, &opt_alias, "If used with --create, create an alias, otherwise just list aliases", NULL },
{ "create", 0, 0, G_OPTION_ARG_STRING, &opt_create, "Create a new ref for an existing commit", "NEWREF" },
{ "collections", 'c', 0, G_OPTION_ARG_NONE, &opt_collections, "Enable listing collection IDs for refs", NULL },
+ { "force", 0, 0, G_OPTION_ARG_NONE, &opt_force, "Overwrite existing refs when creating", NULL },
{ NULL }
};
else goto out;
}
- if (checksum_existing != NULL)
+ if (!opt_force && checksum_existing != NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"--create specified but ref %s already exists", opt_create);
else goto out;
}
- /* We want to allow replacing an existing alias */
+ /* We want to allow replacing an existing alias or a normal ref when
+ * forced
+ */
gboolean replacing_alias = opt_alias && g_hash_table_contains (ref_aliases, opt_create);
- if (!replacing_alias && checksum_existing != NULL)
+ if (!replacing_alias && !opt_force && checksum_existing != NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"--create specified but ref %s already exists", opt_create);
assert_not_reached "refs --create unexpectedly succeeded in overwriting an existing prefix!"
fi
+# Force overwriting ctest and check the revision got updated
+foo_ctest_rev=$(${CMD_PREFIX} ostree --repo=repo rev-parse foo/ctest)
+${CMD_PREFIX} ostree --repo=repo refs foo/ctest --create=ctest --force
+assert_ref repo ctest ${foo_ctest_rev}
+
# https://github.com/ostreedev/ostree/issues/1285
# One tool was creating .latest_rsync files in each dir, let's ignore stuff like
# that.